package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.CommentStatus;
import com.heima.model.common.dtos.CommentAddLikeDto;
import com.heima.model.common.dtos.FindNewsDto;
import com.heima.model.common.dtos.ResponseResult;

import com.heima.model.common.dtos.ReviewDto;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.common.pojos.comment.ApCommentRepay;
import com.heima.wemedia.service.CommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/v1/comment/manage")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @PostMapping("/find_news_comments")
    public ResponseResult findNewsComments(@RequestBody FindNewsDto findNewsDto){

        return commentService.findNewsComments(findNewsDto);
    }

    /**
     * 删除评论
     * @param commentId
     * @return
     */
    @DeleteMapping("/del_comment/{commentId}")
    public ResponseResult deleteComment(@PathVariable String commentId){
        log.info("收到前端发来要删除评论的ID：{}",commentId);
        return commentService.deleteComment(commentId);
    }


    /**
     * 删除回复评论
     * @param commentRepayId
     * @return
     */
    @DeleteMapping("/del_comment_repay/{commentRepayId}")
    public ResponseResult deleteCommentRepay(@PathVariable String commentRepayId){
        log.info("收到前端发来要删除评论回复的ID：{}",commentRepayId);
        return commentService.deleteCommentRepay(commentRepayId);
    }

    /**
     * 回复评论
     * @param apCommentRepay
     * @return
     */
    @PostMapping("/comment_repay")
    public ResponseResult repayComment(@RequestBody ApCommentRepay apCommentRepay){
        log.info("收到前端的回复评论{}",apCommentRepay);
        return commentService.repayComment(apCommentRepay);
    }

    /**
     * 评论点赞
     * @param commentAddLikeDto
     * @return
     */
    @PostMapping("/like")
    public ResponseResult addCommentLike(@RequestBody CommentAddLikeDto commentAddLikeDto){
        log.info("收到前端的点赞操作：{}",commentAddLikeDto);
        return commentService.addCommentLike(commentAddLikeDto);
    }

    @PostMapping("/update_comment_status")
    public ResponseResult updateCommentStatus(@RequestBody CommentStatus commentStatus){


        return commentService.updateStatus(commentStatus);
    }

    @PostMapping("/list")
    public ResponseResult review(@RequestBody ReviewDto reviewDto){
        return commentService.review(reviewDto);
    }
}
